home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac Magazin/MacEasy 43
/
Mac Magazin and MacEasy Magazine CD - Issue 43.iso
/
Software
/
Entwickler
/
ListBox 0.4
/
ListBox.h
< prev
next >
Wrap
Text File
|
1998-02-16
|
3KB
|
87 lines
/********************
ListBox - A simple replacement for the list manager
files: ListBox.h
ListBox.cpp
By Kyle Ellrott
killtherat@bigfoot.com
2/14/98
Feel free to re-use and tear apart this code. But if any part of it is in a program
you release please indicate my name in the credits.
Bugs: I'm sure there are a few. If you find any, please tell me about em.
*******************/
typedef void (*customModalFilter)(DialogPtr destDialog, EventRecord *theEvent, short *itemHit);
class ListBox {
public:
//Initialize
ListBox();
//Trash it
~ListBox();
//Pass the itemNum of something in a dialog box, and this creates the List
void SetupFromItem(DialogPtr theDialog, short itemNum);
//Pass the rectangle where you want the box
void SetupFromRect(DialogPtr theDialog, Rect *rect);
//Shut it Down
void Close(void);
//Call ModalDialog if you want a stanard Modal dialog box with a list
//Note, I haven't done extinsive testing with custom filters
//If you want to roll your own dialog filter it's probably better if you
//Pass the Events to TrackEvent() and use Draw() of the updates
void ModalDialog(customModalFilter modalFilter, DialogItemIndex * itemHit);
//TrackEvents figures out if they clicked on the List
Boolean TrackEvent(EventRecord *theEvent);
void Draw(void);
//Pass the restype, and it will make a list. The item id's are the res numbers...
void MakeResTypeList(long resType);
void AddItem(short idNum, Str255 name);
//Pass the line number of the Item you want to delete
void KillLine(short lineNum);
//This just kills the entire list...
void KillItemList(void);
//Change the order of two lines
void SwapLines(short line1, short line2);
//Find out how many items are in your list
short GetItemCount(void);
//These functions effect which line is highlighted
short GetCurLine(void);
void SetCurLine(short line);
//These functions effect which line is at the top of screen
void SetTopLine(short line);
short GetTopLine(void);
//This gives the ID num of the current selection
short GetCurItem(void);
//Get the ID num of any old line
short GetLineID(short lineNum);
//Makes sure the ScrollBar is set up right. You probably won't need to call it.
void AdjustScrollBar(void);
// The scroll bar is public only because the localScoll
//function needs to call this varible from a global ListBox
ControlHandle theScrollBar;
private:
struct lbItem *items;
DialogPtr destDialog;
Rect destRect;
Point itemSize;
short topLine, curLine;
long lastClick;
};
typedef struct lbItem {
Str255 name;
short idNum;
struct lbItem *next;
}lbItem;